#include "./app_task.h"
#include "./query_task.h"
#include "./handler_task.h"
#include "./uart_recv_task.h"
#include "./status_task.h"

#include "../driver/can_bus.h"
#include "../driver/cmd_uart.h"
#include "../driver/analog.h"

#include "../service/can_recv.h"
#include "../service/master_conn.h"
#include "../service/salve_conn.h"
#include "../conn/conn_type.h"
#include "../device/compat.h"


namespace task {

using namespace driver;
using namespace service;
using namespace conn;

void AppTask::global_init() {
    RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;

    AFIO->MAPR = AFIO_MAPR_SWJ_CFG_JTAGDISABLE
#if defined(BOARD_PICK)
    | (0x02 << 8)
#endif
    ;
}

void AppTask::run() {
    global_init();

    canBus.init();
    cmdUart.init();
    analog.init();

    masterConn.init();
    salveConn.init();

    driver_impl_init();

    queryTask->start();
    handlerTask->start();
    uartRecvTask->start();
    statusTask->start();

    cmdUart->printf("app run:%d", MY_ADDR);
    
    service::can_recv_loop();
}



}






